package com.kehutong.work.order.manage.admin;

import org.coraframework.authz.HasPermission;
import org.coraframework.inject.Inject;
import org.coraframework.json.JSONObject;
import org.coraframework.mvc.MvcAction;
import org.coraframework.mvc.http.Bean;
import org.coraframework.mvc.http.ReqMapping;
import org.coraframework.mvc.http.result.Result;
import com.kehutong.work.order.manage.entity.WorkOrderManageClassify;
import com.kehutong.work.order.manage.service.WorkOrderClassifyService;

/**
 * 管理后台-工单管理-分类管理
 */
@MvcAction
@ReqMapping("/admin/work/order/manage/classify")
public class WorkOrderClassifyController {

    @Inject
    private WorkOrderClassifyService classifyService;

    @HasPermission("work:order:manage:classify:view")
    @ReqMapping("/list/page")
    public Object listPage(JSONObject jsonObject) {
        return classifyService.listPage(jsonObject);
    }

    @ReqMapping("/list")
    public Object list(JSONObject jsonObject) {
        return classifyService.list(jsonObject);
    }

    @ReqMapping("/list/enable")
    public Object listEnable(JSONObject jsonObject) {
        return classifyService.listEnable(jsonObject);
    }

    @HasPermission("work:order:manage:classify:add")
    @Bean(newInstance=true, copy=true)
    @ReqMapping("/save")
    public Object save(WorkOrderManageClassify classify) {

        return classifyService.save(classify);
    }

    @HasPermission("work:order:manage:classify:edit")
    @Bean(copy=true)
    @ReqMapping("/update")
    public Object update(WorkOrderManageClassify classify) {

        return classifyService.update(classify);
    }

    @HasPermission("work:order:manage:classify:del")
    @ReqMapping("/delete")
    public Object delete(WorkOrderManageClassify classify) throws Exception {

        return classifyService.delete(classify);
    }

    @HasPermission("work:order:manage:classify:edit")
    @Bean(copy=true)
    @ReqMapping("/updateSort")
    public Object updateSort(WorkOrderManageClassify classify, Integer sort) throws Exception {

        return classifyService.updateSort(classify, sort);
    }

    @ReqMapping("/get")
    public Object get(WorkOrderManageClassify classify) {

        return Result.success(classify);
    }
}
